﻿using ConfExpert.Forms.Base;

using DevExpress.XtraReports.UI;
using DevTeam;

using System;
namespace ConfExpert.Forms.Destex
{
    public partial class StokDurumu : XForm
    {
        public StokDurumu()
        {
            InitializeComponent();
        }

        private void StokByShelf_Load(object sender, EventArgs e)
        {
            gridView1.Init("DX_GetStokByShelf");
            gridView1.MakeColumnInvisible("ProductId");
            gridView1.FormatAsNumber(1, "Qty", "En");
            gridView1.AddSummary("Qty");
            gridView1.MakeReadOnly("Qty");

            GridManager gm = GridManager.GetManager(gridView1);
            gm.GridMenu.AddMenu("Destex etiketi yazdır", PrintDestexEtiket);

            gridView1.BestFitColumns();

            btnKaydet.ItemClick += btnKaydet_ItemClick;
            btnKaydet.Enabled = MyDept == 26;
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView1.EndEditing();
            ExecuteNonQuery("DX_UpdRollQty", gridView1.SerializeChanges(), WhoAmI);
            Notify("Kaydedildi");
        }
        private void PrintDestexEtiket(object sender, EventArgs e)
        {
            if (gridView1.FocusedRowHandle > -1)
            {
                string RollIds = gridView1.GetSelectedValues("RollId").ToStr();
                Test.DestexEtiket de = new Test.DestexEtiket(RollIds);
                de.ShowPreview();
            }
        }

    }
}
